<template>

  <div>

    <div class="block">

      <el-carousel height="150px">
        <el-carousel-item v-for="(item,index) in images" :key="index">

          <el-image
              :class="className"
              style="width:100%; height:100%;"
              :src="item.idView"
              fit="fit"
          ></el-image>

        </el-carousel-item>
      </el-carousel>
    </div>
    <div style="margin-top: 5%">
      <p class="demonstration" style="text-align: center">活动列表</p>
      <el-table :data="tableData" stripe row-key="id" default-expand-all>
        <el-table-column prop="name" label="名称" width="100"></el-table-column>
        <el-table-column prop="concent" label="活动内容" width="68"></el-table-column>
        <el-table-column prop="time" label="开始时间"   width="100"></el-table-column>
        <el-table-column prop="endtime" label="结束时间" width="100"></el-table-column>
      </el-table>
    </div>

    <div style="text-align: center; bottom: 0">
      <el-pagination
          background
          :current-page="params.pageNum"
          :page-size="params.pageSize"
          layout="prev, pager, next"
          @current-change="handleCurrentChange"
          :total="total">
      </el-pagination>
    </div>
  </div>

</template>

<script>
import Cookies from "js-cookie";
import request from "@/utils/request";


export default {
  name: 'HomeView',
  data() {


    return {
      user: Cookies.get('user') ? JSON.parse(Cookies.get('user')) : {},
      total: 0,
      params: {
        pageNum: 1,
        pageSize: 10,
      },

      images: [
        {id: 0, idView: require('../assets/a.png')},
        {id: 1, idView: require('../assets/b.png')},

      ],
      className: "",

      tableData: []
    }
  },
  mounted() {
    this.className = "lun-img-two";
    setTimeout(() => {
      this.className = "lun-img";
    }, 300);
  },
  created() {
    this.load();

  },


  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },


    load() {
      request.get('/activity/page', {
        params: this.params
      }).then(res => {
        if (res.code === '200') {
          this.tableData = res.data.list
          this.total = res.data.total
        }
      })
    },

    reset() {
      this.params = {
        pageNum: 1,
        pageSize: 10,
      }
      this.load()
    },


    handleCurrentChange(pageNum) {
      this.params.pageNum = pageNum
      this.load()
    },
    changeImg: function (e) {
      this.className = "lun-img-two";
      setTimeout(() => {
        this.className = "lun-img";
      }, 300);
    }


  },




}

</script>

<style>
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.lun-img {
  transition: all 4s;
  transform: scale(1.5);
}

.lun-img-two {
  transform: scale(1);
}

.el-carousel__item.is-animating {
  transition: transform 1s ease-in-out;
}

.el-carousel__item:nth-child(3n) {
  background-image: url("../assets/logo.png");
}

.el-carousel__item:nth-child(3n+1) {
  background-color: #d3dce6;
}

.el-carousel__item:nth-child(3n+2) {
  background-color: #d3dce6;
}
</style>
